package com.health.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.health.entity.Consultingroom;
import com.health.entity.pojo.PageData;

import com.health.entity.Consultingroom;

import com.health.entity.pojo.vo.ConsultingroomVO;
import com.health.mapper.ConsultingroomMapper;
import com.health.service.IConsultingroomService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.ArrayList;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yuqingjiang
<<<<<<<<< Temporary merge branch 1
 * @since 2023-04-17
=========
 * @since 2023-04-15
>>>>>>>>> Temporary merge branch 2
 */
@Service
public class ConsultingroomServiceImpl extends ServiceImpl<ConsultingroomMapper, Consultingroom> implements IConsultingroomService {

    @Autowired
    ConsultingroomMapper consultingroomMapper;

    //下拉框科室查询
    @Override
    public PageData listSelectConsultingroom(@PathVariable("pageNum") Integer pageNum,
                                             @PathVariable("pageSize") Integer pageSize,
                                             Long id) {
        IPage<ConsultingroomVO> iPage =  new Page<>(pageNum,pageSize);
        Page<ConsultingroomVO> consFirst = consultingroomMapper.listSelectConsultingroom(iPage,id);
        for (ConsultingroomVO consultingroomVO : consFirst.getRecords()) {
            List<ConsultingroomVO> consSecond = consultingroomMapper.listAllConsultingrooms(consultingroomVO.getId());
            consultingroomVO.setConsSecond(consSecond);
        }
        return new PageData(consFirst.getTotal(),consFirst.getRecords());
    }

    //科室列表查询
    @Override
    public PageData listAllConsultingrooms(@PathVariable("pageNum") Integer pageNum,
                                           @PathVariable("pageSize") Integer pageSize) {
        IPage<ConsultingroomVO> iPage =  new Page<>(pageNum,pageSize);
        Page<ConsultingroomVO> consIPage = consultingroomMapper.listAllConsultingrooms(iPage,0L);
        for (ConsultingroomVO consultingroomVO : consIPage.getRecords()) {
            List<ConsultingroomVO> consSecond = consultingroomMapper.listAllConsultingrooms(consultingroomVO.getId());
            consultingroomVO.setConsSecond(consSecond);
        }
        return new PageData(consIPage.getTotal(),consIPage.getRecords());
    }

    //编辑科室中二级科室查询
    @Override
    public List<ConsultingroomVO> getConsultingroomByName(Integer i) {
        List<ConsultingroomVO> consultingroomByName = consultingroomMapper.getConsultingroomByName(i);
        return consultingroomByName;
    }



    @Autowired
    ConsultingroomMapper consMapper;





    @Override
    public Boolean updateConsultingroom(Integer id) {
        Boolean aBoolean = consMapper.updateConsultingroom(id);
        return aBoolean;
    }

    @Override
    public List<String> getConsultingRoomsOne() {
        return consMapper.getConsultingRoomsOne();
    }

    @Override
    public List<String> getConsultingRoomsTwo() {
        return consMapper.getConsultingRoomsTwo();
    }

    @Override
    public List<String> getOneConsultRooms() {
        return baseMapper.geOneConsultRooms();

    }
}
